package dilmaj.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.TextBoxBase;
import com.google.gwt.user.client.ui.Widget;

import dilmaj.shared.AreaVO;
import dilmaj.shared.StarEntryVO;
import dilmaj.shared.StarTermVO;

public class StarButtonHandler implements ClickHandler {
	//private StarServiceAsync starSvc = GWT.create(StarService.class);
	private StarPanel starPanel;
	private StarEntryVO dataVO;
	private StarButtonPanel owner;
	
	public StarButtonHandler(StarButtonPanel owner, StarEntryVO dataVO) {
		this.owner=owner;
		this.dataVO=dataVO;
	}
	
	@Override
	public void onClick(ClickEvent event) {
		// TODO Auto-generated method stub
	   /* if (starSvc == null) {
		      starSvc = GWT.create(StarService.class);
		    }*/
	    Button button=(Button)event.getSource();
	    
	    starPanel=owner.getChildPanel();
	    if (starPanel==null)
	    	starPanel=new StarPanel(dataVO, owner);
		starPanel.refreshLogin();
	    
		int left=button.getAbsoluteLeft();
		int top=button.getAbsoluteTop();
		int x=starPanel.getOffsetWidth();
		int y=starPanel.getOffsetHeight();
		starPanel.setPopupPosition(left-(x/2), top-(y/2));
		starPanel.show();
		DataStore.openPanel(starPanel);
	}
}
